home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Creative Computers
/
Creative Computers CD-ROM, Volume 1 (Legendary Design Technologies, Inc.)(1994).iso
/
shareware
/
telecom
/
term_4.1
/
extras
/
hydracom
/
hydracom-source.lha
/
async.asm
< prev
next >
Wrap
Assembly Source File
|
1994-01-19
|
24KB
|
741 lines
;==============================================================================
;
; HydraCom Version 1.00
;
; A sample implementation of the
; HYDRA Bi-Directional File Transfer Protocol
;
; HydraCom was written by
; Arjen G. Lentz, LENTZ SOFTWARE-DEVELOPMENT
; COPYRIGHT (C) 1991-1993; ALL RIGHTS RESERVED
;
; The HYDRA protocol was designed by
; Arjen G. Lentz, LENTZ SOFTWARE-DEVELOPMENT and
; Joaquim H. Homrighausen
; COPYRIGHT (C) 1991-1993; ALL RIGHTS RESERVED
;
;
; Revision history:
; 06 Sep 1991 - (AGL) First tryout
; .. ... .... - Internal development
; 11 Jan 1993 - HydraCom version 1.00, Hydra revision 001 (01 Dec 1992)
;
;
; For complete details of the Hydra and HydraCom licensing restrictions,
; please refer to the license agreements which are published in their entirety
; in HYDRACOM.C and LICENSE.DOC, and also contained in the documentation file
; HYDRACOM.DOC
;
; Use of this file is subject to the restrictions contained in the Hydra and
; HydraCom licensing agreements. If you do not find the text of this agreement
; in any of the aforementioned files, or if you do not have these files, you
; should immediately contact LENTZ SOFTWARE-DEVELOPMENT and/or Joaquim
; Homrighausen at one of the addresses listed below. In no event should you
; proceed to use this file without having accepted the terms of the Hydra and
; HydraCom licensing agreements, or such other agreement as you are able to
; reach with LENTZ SOFTWARE-DEVELOMENT and Joaquim Homrighausen.
;
;
; Hydra protocol design and HydraCom driver: Hydra protocol design:
; Arjen G. Lentz Joaquim H. Homrighausen
; LENTZ SOFTWARE-DEVELOPMENT 389, route d'Arlon
; Langegracht 7B L-8011 Strassen
; 3811 BT Amersfoort Luxembourg
; The Netherlands
; FidoNet 2:283/512, AINEX-BBS +31-33-633916 FidoNet 2:270/17
; arjen_lentz@f512.n283.z2.fidonet.org joho@ae.lu
;
; Please feel free to contact us at any time to share your comments about our
; software and/or licensing policies.
;
;==============================================================================
IDEAL
IFDEF MODL
MODEL MODL
ELSEIFDEF _SMALL
MODEL SMALL
ELSEIFDEF _LARGE
MODEL LARGE
ENDIF
EOI equ 020h ; 8259 end-of-interupt
Ctrl8259_0 equ 020h ; 8259 port
Ctrl8259_1 equ 021h ; 8259 port (Masks)
BufSize equ 4100 ; Buffer Size
DATASEG
; Various things to be set upon AsyncInit()
VectorNum db ? ; Vector Number
EnableIRQ db ? ; Mask to enable 8259 IRQ
DisableIRQ db ? ; Mask to disable 8259 IRQ
VectorSeg dw ? ; Old Vector Segment
VectorOfs dw ? ; Old Vector Offset
Fifo db ? ; Nonzero if 16550 FIFO enabled
CTShand dw ? ; Nonzero if CTS handshaking ok
; Register Addresses for the 8250 UART
Port dw ? ; Port Base Address
LABEL RegStart word
THR dw ? ; Transmitter Holding Register
RDR dw ? ; Receiver Data Register
BRDL dw ? ; Baud Rate Divisor, Low byte
BRDH dw ? ; Baud Rate Divisor, High Byte
IER dw ? ; Interupt Enable Register
IIR dw ? ; Interupt Identification Reg
FCR dw ? ; FIFO Control Register
LCR dw ? ; Line Control Register
MCR dw ? ; Modem Control Register
LSR dw ? ; Line Status Register
MSR dw ? ; Modem Status Register
; Register Offsets for the UART
RegOffsets dw 0, 0, 0, 1, 1, 2, 2, 3, 4, 5, 6
; Buffer Data
RecBuffer db BufSize DUP (?) ; Receive Buffer
RecHead dw ? ; Buffer Head Pointer
RecTail dw ? ; Buffer Tail Pointer
TransBuffer db BufSize DUP (?) ; Transmit Buffer
TransHead dw ? ; Buffer Head Pointer
TransTail dw ? ; Buffer Tail Pointer
CODESEG
PUBLIC _AsyncInit, _AsyncDump, _AsyncPurge, _AsyncStop
PUBLIC _AsyncIn, _AsyncOut, _AsyncSet
PUBLIC _AsyncHand, _AsyncStat, _AsyncInStat
PUBLIC _AsyncOutStat, _AsyncCTS, _AsyncFifo
;-----------------------------------------------------------------------------
; AsyncDump Empty the transmit buffer
;-----------------------------------------------------------------------------
; void AsyncDump (void);
;
;
;-----------------------------------------------------------------------------
PROC _AsyncDump
cli
push ax
mov ax, offset TransBuffer
mov [TransHead], ax
mov [TransTail], ax
pop ax
sti
ret
ENDP _AsyncDump
;-----------------------------------------------------------------------------
; AsyncPurge Empty the receive buffer
;-----------------------------------------------------------------------------
; void AsyncPurge (void);
;
;
;-----------------------------------------------------------------------------
PROC _AsyncPurge
cli
push ax
mov ax, offset RecBuffer
mov [RecHead], ax
mov [RecTail], ax
pop ax
sti
ret
ENDP _AsyncPurge
;-----------------------------------------------------------------------------
; AsyncInit Initalize Serial Port and install ISR
;-----------------------------------------------------------------------------
; void AsyncInit( int port)
;
; Where Port is
; 0 = COM1
; 1 = COM2
; 2 = COM3
; 3 = COM4
;
;-----------------------------------------------------------------------------
PROC _AsyncInit
ARG CommPort:word
push bp
mov bp, sp
;---- Set various things according to com port number
mov ax, [CommPort]
;----- COM1
cmp ax, 0
jne @@1
mov [Port], 03F8h
mov [VectorNum], 0Ch
mov [EnableIRQ], 0EFh
mov [DisableIRQ], 10h
jmp short @@Done
@@1:
;----- COM2
cmp ax, 1
jne @@2
mov [Port], 02F8h
mov [VectorNum], 0Bh
mov [EnableIRQ], 0F7h
mov [DisableIRQ], 08h
jmp short @@Done
@@2:
;----- COM3
cmp ax, 2 ; 2
jne @@3
mov [Port], 03E8h ; 03E8
mov [VectorNum], 0Ch ; 0C
mov [EnableIRQ], 0EFh ; EF
mov [DisableIRQ], 10h ; 10
jmp short @@Done
@@3:
;----- COM4
mov [Port], 02E8h ; 02E8
mov [VectorNum], 0Bh ; 0B
mov [EnableIRQ], 0F7h ; F7
mov [DisableIRQ], 08h ; 08
@@Done:
;---- Compute Register locations
mov cx, 11
mov bx, offset RegOffsets
push di
mov di, offset RegStart
@@4:
mov ax, [bx]
add ax, [Port]
mov [di], ax
add bx, 2
add di, 2